package com.game.netty.http.request;

import com.game.common.utils.CommonField;
import com.game.netty.error.GameCenterError;
import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class LoginParam extends AbstractHttpRequestParam {
    private String openid;
    private String token;

    private String ip;


    @Override
    protected void haveError() {
        // 验证登陆参数
        if (StringUtils.isEmpty(openid)) {
            this.error = GameCenterError.OPENID_IS_EMPTY;
        } else if (openid.length() > CommonField.OPEN_ID_LENGTH) {
            this.error = GameCenterError.OPENID_LEN_ERROR;
        } else if (StringUtils.isEmpty(token)) {
            this.error = GameCenterError.SDK_TOKEN_ERROR;
        } else if (token.length() > 128) {
            this.error = GameCenterError.SDK_TOKEN_LEN_ERROR;
        }
    }


}
